//路由管理
import 'package:flutter/material.dart';
import 'package:matuo/page/tool/ScanDevicePage.dart';

import '../page/tob_page/TobPage.dart';

class Routes {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case RoutePath.tab:
        return pageRoute(const TobPage(), settings: settings);

      // case RoutePath.qr:
      //   Logcat.instance.d("执行了这里吗？");
      //   return pageRoute(const QrPage(camera: ""), settings: settings);

      case RoutePath.scan:
        return pageRoute(const ScanDevicePage());
    }

    return MaterialPageRoute(
        builder: (context) =>
            Scaffold(body: Center(child: Text('路由：${settings.name}不存在'))));
  }

  static MaterialPageRoute pageRoute(Widget page,
      {RouteSettings? settings,
      bool? fullscreenDialog,
      bool? allowSnapshotting,
      bool? barrierDismissible}) {
    return MaterialPageRoute(
        builder: (context) => page,
        settings: settings,
        fullscreenDialog: fullscreenDialog ?? false,
        allowSnapshotting: allowSnapshotting ?? true,
        barrierDismissible: barrierDismissible ?? false);
  }
}

class RoutePath {
  static const String tab = "/";

  static const String qr = "/qr";

  static const String scan = "/scan";

  static const String connect = "/connect";
}
